﻿/*
 *Copyright (c) 2008, Scendix Software, Inc.
 * 
 */
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.MediaCenter.UI;

namespace mceTapiRexv2
{
    public class CallMember
    {
        private String name;
        private String id;
        private Image picture;
        private String guid;
        private bool isCaller;
        
        public CallMember(string name, string id, string guid,bool isCaller)
        {
            this.name = name;
            this.id = id;
            this.guid = guid;
            this.isCaller = isCaller;
            loadPicture();
        }
        private void loadPicture()
        {
            this.picture = mceTapiRexv2.Application.Current.getPicture(guid,id);
        }
        public String Name
        {
            get { return name; }
            set { name = value; }
        }
        public String DisplayName
        {
            get
            {
                if (name != "")
                {
                    return name;
                }
                else return id.ToString();
            }
            set { name = value; }
        }
        public void findInContacts()
        {
            Contact contact = null; 
            if (guid != "")
            {
                //Contact is either in Database or in Outlook
                if (mceTapiRexv2.Application.Current.isOutlookPrimarySource())
                    contact = mceTapiRexv2.Application.Current.getContactFromOutlook(guid, this.picture);
                else
                {
                    if(mceTapiRexv2.Application.Current.isDatabasePrimarySource())
                        contact = mceTapiRexv2.Application.Current.getContactFromDatabase(guid, this.picture);
                }
            }
            else
            {
                contact = mceTapiRexv2.Application.Current.getContactFromSkype(id);
            }
            if(contact !=null)
                mceTapiRexv2.Application.Current.GoToPage("Contacts","ContactDetails","Contact",contact);
        }
        public String Id
        {
            get { return id; }
            set { id = value; }
        }
        public String Guid
        {
            get { return guid; }
            set { guid = value; }
        }
        public String PicturePath
        {
            get
            {
                if (picture != null)
                    return  mceTapiRexv2.Application.Current.getPicturePath(guid, id);
                else return "C:\\Scendix\\mceTapiRexv2CP\\Images\\scendix.gif";
            }
            set { }
        }
        public Image Picture
        {
            get {
                if (picture != null)
                    return picture;
                else
                    return new Image("resx://mceTapiRexv2/mceTapiRexv2.Resources/Unknown");
             }
            set { picture = value; }
        }

    }
}

